#include<iostream>
using namespace std;
typedef long long LL;
const int N=1e5+10; 
int n,m;
LL f[N];
int main(){
	cin>>n>>m;
	int city;
	cin>>city;
	for(int i=2;i<=m;i++){
		int tmp;
		cin>>tmp;
		if(city>tmp){
			f[tmp]++;
			f[city]--;
		}else{
			f[city]++;
			f[tmp]--;
		}
		city=tmp;
	}
	
	for(int i=1;i<=n;i++){
		f[i]=f[i-1]+f[i];
	}
	LL ret=0;
	for(int i=1;i<n;i++){
		LL A,B,C;
		cin>>A>>B>>C;
		ret+=min(A*f[i],C+B*f[i]);
	}
	cout<<ret<<endl;
	return 0;
} 
